//
//  ViewController.m
//  ios
//
//  Created by Macbook on 16-4-25.
//  Copyright (c) 2016年 。。. All rights reserved.
//

#import "ViewController.h"
#import "Rpw.h"
@interface ViewController ()
{
    NSArray *data;
}
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    UITableView *tableView=[[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    tableView.dataSource=self;
    [self.view addSubview:tableView];
    NSBundle  *bunble=[NSBundle mainBundle];
    NSURL *url=[bunble URLForResource:@"tel" withExtension:@""];
    NSString *text= [[NSString alloc]initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
    NSLog(@"读取数据:%@",text);
    NSArray *arr=[text componentsSeparatedByString:@"\n"];
    NSMutableArray *tmp=[NSMutableArray new];
    for (int i=0;i<arr.count;i++) {
        NSString *item=arr[i];
        NSArray *p=[item componentsSeparatedByString:@","];
        Rpw *r=[Rpw new];
        r.name= p[0];
        r.tel = p[1];
        [tmp addObject:r];
    }
    data=tmp;
    
}
-(NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 {
    
    return data.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    cell.textLabel.text=data[indexPath.row];
    return cell;
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
